package image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

public class LoadImage extends JFrame {

	public LoadImage(String imgStr, Mat m, String title, boolean isFloat, int x, int y) {

		if(isFloat)
			for(int i=0; i<m.size().height; i++)
				for(int j=0; j<m.size().width; j++)
					m.put(i, j, m.get(i, j)[0]*255);
		
		Highgui.imwrite(imgStr,m);
		JFrame frame = new JFrame(title);

		frame.setResizable(true);
		frame.setLocation(x, y);
		//frame.setLocationRelativeTo(null);

		// Inserts the image icon
		ImageIcon image = new ImageIcon(imgStr);
		frame.setSize(image.getIconWidth()+10,image.getIconHeight()+35);
		// Draw the Image data into the BufferedImage
		JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
		frame.getContentPane().add(label1);

		frame.validate();
		frame.setVisible(true);
		
		}
}
